<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::AtomFeedHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::AtomFeedHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper_rb.html">
                vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000931">atom_feed</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Class <a href="AtomFeedHelper/AtomFeedBuilder.html" class="link">ActionView::Helpers::AtomFeedHelper::AtomFeedBuilder</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000931" class="method-detail">
        <a name="M000931"></a>

        <div class="method-heading">
          <a href="#M000931" class="method-signature">
          <span class="method-name">atom_feed</span><span class="method-args">(options = {}) {|AtomFeedBuilder.new(xml, self)| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Full usage example:
</p>
<pre>
  config/routes.rb:
    ActionController::Routing::Routes.draw do |map|
      map.resources :posts
      map.root :controller =&gt; &quot;posts&quot;
    end

  app/controllers/posts_controller.rb:
    class PostsController &lt; ApplicationController::Base
      # GET /posts.html
      # GET /posts.atom
      def index
        @posts = Post.find(:all)

        respond_to do |format|
          format.html
          format.atom
        end
      end
    end

  app/views/posts/index.atom.builder:
    atom_feed do |feed|
      feed.title(&quot;My great blog!&quot;)
      feed.updated((@posts.first.created_at))

      for post in @posts
        feed.entry(post) do |entry|
          entry.title(post.title)
          entry.content(post.body, :type =&gt; 'html')

          entry.author do |author|
            author.name(&quot;DHH&quot;)
          end
        end
      end
    end
</pre>
<p>
The options are for <a href="AtomFeedHelper.html#M000931">atom_feed</a>
are:
</p>
<ul>
<li><tt>:language</tt>: Defaults to &quot;en-US&quot;.

</li>
<li><tt>:root_url</tt>: The HTML alternative that this feed is doubling for.
Defaults to / on the current host.

</li>
<li><tt>:url</tt>: The URL for this feed. Defaults to the current URL.

</li>
</ul>
<p>
<a href="AtomFeedHelper.html#M000931">atom_feed</a> yields a <a
href="AtomFeedHelper/AtomFeedBuilder.html">AtomFeedBuilder</a> instance.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000931-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000931-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb, line 52</span>
52:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">atom_feed</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
53:         <span class="ruby-identifier">xml</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:xml</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">eval</span>(<span class="ruby-value str">&quot;xml&quot;</span>, <span class="ruby-identifier">block</span>.<span class="ruby-identifier">binding</span>)
54:         <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">instruct!</span>
55: 
56:         <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">feed</span> <span class="ruby-value str">&quot;xml:lang&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:language</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;en-US&quot;</span>, <span class="ruby-value str">&quot;xmlns&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'http://www.w3.org/2005/Atom'</span> <span class="ruby-keyword kw">do</span>
57:           <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">id</span>(<span class="ruby-node">&quot;tag:#{request.host}:#{request.request_uri.split(&quot;.&quot;)[0].gsub(&quot;/&quot;, &quot;&quot;)}&quot;</span>)      
58:           <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">link</span>(<span class="ruby-identifier">:rel</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'alternate'</span>, <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'text/html'</span>, <span class="ruby-identifier">:href</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:root_url</span>] <span class="ruby-operator">||</span> (<span class="ruby-identifier">request</span>.<span class="ruby-identifier">protocol</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">host_with_port</span>))
59: 
60:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:url</span>]
61:             <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">link</span>(<span class="ruby-identifier">:rel</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'self'</span>, <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'application/atom+xml'</span>, <span class="ruby-identifier">:href</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:url</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">url</span>)
62:           <span class="ruby-keyword kw">end</span>
63: 
64:           <span class="ruby-keyword kw">yield</span> <span class="ruby-constant">AtomFeedBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-keyword kw">self</span>)
65:         <span class="ruby-keyword kw">end</span>
66:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>